// pages/approval/reward/detail/detail.js
//获取应用实例
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    backImg: app.globalData.iconImgUrl+"arrow-left.svg",
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    backIcon: true,
    title: "审核详情",
    formeImg: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.id)
    this.getDetail(options.id)
  },
  getDetail(id) {
    const that = this
    wx.request({
      url: app.globalData.baseUrl + 'reward/xsAuditDetails.do',
      method: 'post',
      data: {
        id: id,
        userCode: wx.getStorageSync('userCode')
      },
      success(res) {
        // console.log(res)
        const details = res.data.details
        const imgArr = []
        let auditType
        
        console.log(details)
        if ( details.img1 !== '' && details.img1 !== null ) {
          imgArr.push(details.img1)
        }
        if (details.img2 !== '' && details.img2 !== null) {
          imgArr.push(details.img2)
        }
        if (details.img3 !== '' && details.img3 !== null) {
          imgArr.push(details.img3)
        }
        switch (details.auditType) {
          case -1:
            auditType = '未完成'
            break;
          case 0:
            auditType = '未审批'
            break
          case 1:
            auditType = '及格'
            break
          case 2:
            auditType = '满意'
            break
          default:
            break
        }

        that.setData({
          content: details.content,
          markName: details.markName,
          mark: details.mark,
          markType: details.markType,
          teamNum: details.teamNum,
          formeImg: imgArr,
          auditType: auditType
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})